@extends('welcome')
<link rel="stylesheet" href="/Home/User/css/safe/ms-style.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/personal_member.min.css" />
<link rel="stylesheet" href="/Home/User/css/safe/Snaddress.min.css" />
<link rel="stylesheet" href="/Home/login/css/landreg.css" />
<!-- 表格样式 -->
<link rel="stylesheet" href="/Home/address/css.css" />
<link rel="stylesheet" href="/Home/address/sui.css" />
<link rel="stylesheet" href="/Home/address/common.min.css" />
<!--导入地区联动插件-->
<script type="text/javascript" src="/Home/UserEdit/jquery.js"></script>
<script type="text/javascript" src="/Home/UserEdit/area.js"></script>
<script type="text/javascript" src="/Home/UserEdit/location.js"></script>
<!-- 三级联动样式引入 -->
<link rel="stylesheet" href="/Home/address/commonnn.css" />
@section('titletitle','地址管理--优品惠')
@section('zhong_content')
  <br/>
  <!-- 用户中心开始 -->
  <div id="ms-center" class="personal-member">
    <div class="cont">
      <div class="cont-side">
        <div class="side-neck">
          <i></i>
        </div>
        <div class="ms-side">
          <article class="side-menu side-menu-off">
            <dl class="side-menu-tree">
              <dt>订单管理</dt>
              <dd><a  href="{{url('/home/order/xiangqing')}}" target="_self"><span class="active"></span>订单中心</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>账户管理</dt>
              <dd><a href="{{url('home/user/edit')}}" target="_self"><span class="active"></span>我的资料</a></dd>
              <dd><a href="{{url('home/user/password')}}" target="_self"><span class="active"></span>密码修改</a></dd>
              <dd><a href="{{url('home/user/address')}}" target="_self" style="color:#f70"><span></span>地址管理</a></dd>
            </dl>
            <dl class="side-menu-tree">
              <dt>收藏管理</dt>
              <dd><a href="{{url('home/collect/index')}}" target="_self"><span class="active"></span>收藏列表</a></dd>
            </dl>
            <a ison="on" class="switch-side-menu icon-up-side"><i></i></a>
          </article>
        </div>
      </div>
      <div class="cont-main">
        <div class="main-wrap mt15">
        @if(session('error'))
          {{session('error')}}
        @endif

        @if (count($errors) > 0)
          <div class="">
            <ul>
              @foreach ($errors->all() as $error)
                <div class="cont-main alert alert-danger alert-dismissable" style="width:400px">
                  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                  <li>{{ $error }}</li>
                </div>
              @endforeach
            </ul>
          </div>
        @endif

        @if(session('success'))
        <div class="cont-main alert alert-success alert-dismissable" style="width:400px">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
            <h5> {{session('success')}} </h5>
        </div>
        @endif
        @if(session('error'))
        <div class="cont-main alert alert-danger alert-dismissable" style="width:400px">
           <h5> {{session('error')}} </h5>
        </div>
        @endif
           <div class="cont-main">
        <div class="main-wrap mt15">
          

          
          <h3>
            <strong>我的订单</strong>
          </h3>
<?php 
                      $i = 0;
                   ?>
          <!-- 我的订单 -->
           @foreach($orders as $k=>$v)
          <div class="container" style="width:1000px;margin-bottom:10px;border:1px #E9E9E9 solid">
           <div class="row" style="width:998px;height:30px;background:#F7F7F7;">
              <div class="col-lg-1" style="height:30px;">
                <div style="width:60px;height:22px;background:#56ADFA;color:#FCFCFC ;text-align:center;line-height:22px;margin-top:5px;">网站订单</div>

              </div>
              <div class="col-lg-3" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">订单编号：{{$v->dingdan_id}}</div>
              </div>     
              <div class="col-lg-4" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">下单时间：{{$v->atime}}</div>
              </div>      
              <div class="col-lg-4" style="height:30px;"></div>      

           </div>
           <div class="row" style="line-height:80px;">
             <div class="col-lg-1" style="height:80px;line-height:80px;">
               <div style="height:60px;text-align:center;line-height:60px;"><img style="height:60px;" src="/uploads/{{$v->dingdan_pic}}" alt=""></div>
             </div>
              <div class="col-lg-3" style="height:80px;">
                <div class="row">
                  <div class="col-lg-12">
                    <div  style="height:22px;text-align:center;line-height:22px;">{{$v->dingdan_name}}</div></div>
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">颜色：{{str_replace([1,2,3,4,5,6,7],['红色','黄色','蓝色','绿色','黑色','白色'],$v->dingdan_color)}}</div></div>      
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">尺码：{{str_replace([1,2,3,4,5],['S','M','L','XL','XXL'],$v->dingdan_size)}}</div></div>      
               </div>
              </div>     
              <div class="col-lg-2" style="height:80px;">
                <div>价格: {{$v->price}}</div>
              </div>      
              <div class="col-lg-1" style="height:80px;">
                <div>数量: {{$v->dingdan_num}}</div>
              </div>
              <div class="col-lg-1" style="height:80px;border-left:1px #E9E9E9 solid;border-right:1px #E9E9E9 solid">
                <div class="row">
                  <div class="col-lg-12">
                    <div  style="height:22px;text-align:center;line-height:22px;">{{$v->price*$v->dingdan_num}}</div></div>
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">(<span style="color:#0052CE">免运费</span>)</div></div>      
                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">支付宝</div></div>      
               </div>
              </div>
              <div class="col-lg-1" style="height:80px;">
                <div class="row">
                  <div class="col-lg-12">
                    <div  style="height:22px;text-align:center;line-height:22px;color:red;">已取消</div>
                  </div>

                  <div class="col-lg-12">
                    <div style="height:22px;text-align:center;line-height:22px;">
                          <!-- <button class="btn btn-default" data-toggle="modal" data-target="#myModal" style="font-size:14px">查看详情</button> -->
                              <a data-toggle="modal" data-target="#myModal<?php echo $i;?>">查看详情</a>
                              <div class="modal fade" id="myModal<?php echo $i;?>"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                      <h4 class="modal-title" id="myModalLabel">订单详情</h4>
                                    </div>
                                    <div class="modal-body">
                                            <!-- 订单详情 -->
                                   
                                            <div class="form-list tab-switch personal-wrap-show aa" style="">
                                                  <div class="row" style="">
                                                      <div class="col-lg-12" >
                                                        <div class="col-lg-2" style="">订单详情</div>
                                                      </div> 
                                                      <div class="col-lg-12" style="">
                                                          <div class="col-lg-3">&nbsp;&nbsp;| 订单状态:</div>
                                                          <div class="col-lg-2">{{str_replace([1,2,3],['已付','未付','已取消'],$v->status)}}</div>
                                                      </div>
                                                  </div>
                                                  <div class="row">
                                                          <div class="col-lg-12" style="">
                                                            <div class="col-lg-2" style="">订单信息</div>

                                                          </div>
                                                          <div class="col-lg-12" style="">
                                                            <div class="col-lg-8" style="">&nbsp;&nbsp; 订单编号：{{$v->dingdan_id}}&nbsp; 下单时间：{{date('Y-m-d H:i:s',$v->atime)}}</div>
                                                          </div>
                                                          <div class="col-lg-12" style="">
                                                            <div class="col-lg-12" style="">                          
                                                              <div class="col-lg-2">收货信息</div>
                                                              <div class="col-lg-9">{{$v->dizhi_name}} {{$v->sheng}} {{$v->shi}} {{$v->xian}} {{$v->content}}</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">支付方式:</div>
                                                              <div class="col-lg-2">{{str_replace([1,2],['在线支付','货到付款'],$v->status)}}</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                               <div class="col-lg-2">配送商家:</div>
                                                               <div class="col-lg-8">优品惠官方网站</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">买家留言:</div>
                                                              <div class="col-lg-8">工作日、双休日与节假日均可送货</div>
                                                            </div>
                                                            <div class="col-lg-12" style="">
                                                              <div class="col-lg-2">发票信息:</div>
                                                              <div class="col-lg-2">无 </div>
                                                            </div>
                                                              
                                                          </div>
                                                  </div>
                                                 
                                            </div> 

                                            <!-- 订单详情 end -->     
                                    </div>
                                  </div>
                                </div>
                              </div>

                    </div>
                  </div>      
                        
                </div>
              </div>
              <div class="col-lg-1" style="height:80px;border-left:1px #E9E9E9 solid;border-right:1px #E9E9E9 solid">
                <div style="height:22px;text-align:center;line-height:22px;">再次购买</div>
              </div>
              <div class="col-lg-2" style="height:80px;">
                <div style="height:22px;text-align:center;line-height:22px;"><span style="color:#0052CE;font-weight:bold;width:15px;">+</span>更多</div>
              </div>
           </div>
          </div>
<?php 
$i++;

 ?>
           @endforeach
<div class="col-md-offset-4">
  
          {!! $orders->render() !!}
</div>
          <!-- 我的订单 end -->
          </div>
        </div>
    </div>
  </div>
  <!-- 用户中心结束 -->
@endsection
@section('myjs')
<script type="text/javascript">
//地址删除
$.ajaxSetup({
    headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    }
});
    $('.delete').click(function(){
      var id = $(this).parents('tr').find('.sid').html();
      // alert(id);
      var dd = $(this);
      //发送ajax
      $.post('/home/user/addressdelete',{id:id},function(data){
        if(data == 1){
          dd.parents('tr').remove();
          alert('删除成功');
        }else{
          alert('删除失败');
        }
      })
      return false;
    })
    //三级联动地址
  $(document).ready(function() {
    showLocation();
    $('.addresses .add').each(function(){
      var str = $(this).attr('add');
      // alert(str);
      var info = getInfo(str);
      // alert(info);
      // console.log(info);
      $(this).html(info);
    });

    //定义获取城市信息方法
    function getInfo(str){
      // console.log(str);
      //拆分字符串
      var arr = str.split(',');
      // console.log(arr);  
      var ls  = new Location;
      var l = ls.items;
      // console.log(l['0,1,2']['5']);
      var sheng = l['0'][arr[0]];
      var shi = l['0,'+arr[0]][arr[1]];
      var xian = l['0,'+arr[0]+','+arr[1]][arr[2]];
      return sheng+shi+xian;
    }

    // //点击选中默认地址
    // $('#addresses .item').each(function(){
    //   $(this).click(function(){
    //     //
    //     $('#addresses .item').removeClass('aa');  
    //     $(this).addClass('aa');
    //     //获取当前点击的地址id
    //     var id  = $(this).attr('aid');  
    //     $('input[name=address_id]').val(id);
    //   })
    // })        
  });
  </script>
@show